package org.spring.springcar.controller;

import org.spring.springcar.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

@Controller
public class UserController {

//    private String name;
//
//    public void setName(String name) {
//        this.name = name;
//    }


    /**
     * 属性输入
     */
//    @Autowired
//    private UserService userService;


    /**
     * 构造方法注入
     */
//    private UserService userService;
//
//    public UserController() {
//    }
//
//    @Autowired          //有两个构造方法时，用@Autowired来规定使用哪个构造方法
//    public UserController(UserService userService) {
//        this.userService = userService;
//    }
//



    /**
     * Setter注入
     */
    private UserService userService;

    @Autowired
    public void setUserService(UserService userService) {
        this.userService = userService;
    }

    public void hello() {
        System.out.println("hello,UserController......");

        userService.hello();
    }




}
